package com.yuxinmuyu.sports_management.controller.publicController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuxinmuyu.sports_management.bean.entiy.SNews;
import com.yuxinmuyu.sports_management.bean.request.PageRequest;
import com.yuxinmuyu.sports_management.exception.R;
import com.yuxinmuyu.sports_management.service.SNewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("/newsFile")
@Api(value = "新闻附件表")
public class NewsFileController {
    @Resource
    private SNewsService sNewsService;
    @ApiOperation("获取新闻分页列表")
    @PostMapping("/getPage")
    public R<Page<SNews>>getPage(@RequestBody @Validated PageRequest request){
        return R.success(sNewsService.getPage(request));
    }
    @ApiOperation("发布新闻接口")
    @PostMapping("/adm/add")
    public R<?>getPage(@RequestBody @Validated SNews request){
        sNewsService.add(request);
        return R.success("发布成功！");
    }
    @ApiOperation("删除新闻")
    @PostMapping("/adm/delete")
    public R<?> delete(@RequestBody @Validated SNews request){
        sNewsService.delete(request);
        return R.success("删除成功！");
    }
}